package it.unibz.ti2.internetPizzeria.utils;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Provides redirect method for servlets
 */
public class ServletUtil {

	/**
	 * Redirects to specified url
	 * @param request servlet request
	 * @param response servlet response
	 * @param url redirect destination
	 * @throws ServletException
	 * @throws IOException
	 */
	public static void redirect(HttpServletRequest request,
			HttpServletResponse response, String url) throws ServletException,
			IOException {
		RequestDispatcher rd = request.getRequestDispatcher(url);
		rd.forward(request, response);
	}
}
